package com.sdtw.bookshop.shop.controller;

import com.sdtw.bookshop.shop.bean.BookKindInfo;
import com.sdtw.bookshop.shop.service.BookClassService;
import com.sdtw.bookshop.shop.service.BookKindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class BookClassController {
    @Autowired
    private BookClassService bookClassService;
    @Autowired
    private BookKindService bookKindService;

    @RequestMapping(value = "/findClass", produces = {"application/json;charset=utf-8"})
    public String findAllClass(Model mv1,Model mv2) {
        mv1.addAttribute("BOOKCLASS",bookClassService.findAll());
        mv2.addAttribute("BOOKKIND",bookKindService.findAll());
        return "merchandiseInformationAdd.htm";
    }
    @RequestMapping(value = "/findtype", produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public List<BookKindInfo> findAllClass1() {
        return bookKindService.findAll();
    }
    @RequestMapping(value = "/findkind", produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public List<BookKindInfo> findAllClass2() {
        return bookKindService.findAll();
    }
}
